In [1]:
import pandas as pd
import plotly.express as px
import numpy as np
import plotly.graph_objects as go
/Users/lettyuy/opt/anaconda3/lib/python3.9/site-packages/scipy/__init__.py:155: UserWarning: A NumPy version >=1.18.5 and <1.25.0 is required for this version of SciPy (detected version 1.26.0
  warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"
In [2]:
df = pd.read_csv("Hot 100.csv")
df['chart_date'] = pd.to_datetime(df['chart_date'])
df['chart_debut'] = pd.to_datetime(df['chart_debut'])
df.head()
Out[2]:
chart_position chart_date song performer song_id instance time_on_chart consecutive_weeks previous_week peak_position worst_position chart_debut chart_url
0 84 1990-05-05 "B" Girls Young And Restless "B" GirlsYoung And Restless 1.0 1 NaN NaN 84 84 1990-05-05 https://www.billboard.com/charts/hot-100/1990-...
1 78 1990-05-12 "B" Girls Young And Restless "B" GirlsYoung And Restless 1.0 2 1.0 84.0 78 84 1990-05-05 https://www.billboard.com/charts/hot-100/1990-...
2 68 1990-05-19 "B" Girls Young And Restless "B" GirlsYoung And Restless 1.0 3 2.0 78.0 68 84 1990-05-05 https://www.billboard.com/charts/hot-100/1990-...
3 60 1990-05-26 "B" Girls Young And Restless "B" GirlsYoung And Restless 1.0 4 3.0 68.0 60 84 1990-05-05 https://www.billboard.com/charts/hot-100/1990-...
4 58 1990-06-02 "B" Girls Young And Restless "B" GirlsYoung And Restless 1.0 5 4.0 60.0 58 84 1990-05-05 https://www.billboard.com/charts/hot-100/1990-...
In [3]:
df['chart_year'] = df['chart_date'].dt.year
In [4]:
avg_chart_positions = df.groupby(['song', 'performer'])['chart_position'].mean().round().astype(int).reset_index()
avg_chart_positions = avg_chart_positions.rename(columns={'chart_position': 'avg_chart_position'})
df = pd.merge(df, avg_chart_positions, on=['song', 'performer'], how='left')
In [5]:
df_at_1 = df[df['chart_position'] == 1]
In [6]:
df_at_1.head()
Out[6]:
chart_position chart_date song performer song_id instance time_on_chart consecutive_weeks previous_week peak_position worst_position chart_debut chart_url chart_year avg_chart_position
455 1 1990-09-29 (Can't Live Without Your) Love And Affection Nelson (Can't Live Without Your) Love And AffectionNe... 1.0 13 12.0 4.0 1 93 1990-07-07 https://www.billboard.com/charts/hot-100/1990-... 1990 40
610 1 1991-07-27 (Everything I Do) I Do It For You Bryan Adams (Everything I Do) I Do It For YouBryan Adams 1.0 5 4.0 4.0 1 53 1991-06-29 https://www.billboard.com/charts/hot-100/1991-... 1991 22
611 1 1991-08-03 (Everything I Do) I Do It For You Bryan Adams (Everything I Do) I Do It For YouBryan Adams 1.0 6 5.0 1.0 1 53 1991-06-29 https://www.billboard.com/charts/hot-100/1991-... 1991 22
612 1 1991-08-10 (Everything I Do) I Do It For You Bryan Adams (Everything I Do) I Do It For YouBryan Adams 1.0 7 6.0 1.0 1 53 1991-06-29 https://www.billboard.com/charts/hot-100/1991-... 1991 22
613 1 1991-08-17 (Everything I Do) I Do It For You Bryan Adams (Everything I Do) I Do It For YouBryan Adams 1.0 8 7.0 1.0 1 53 1991-06-29 https://www.billboard.com/charts/hot-100/1991-... 1991 22
In [7]:
unique_songs_at_1 = df_at_1.groupby(['performer', 'song']).size().reset_index().rename(columns={0: 'count'})
performer_hits = unique_songs_at_1.groupby('performer').size()
performer_hits
Out[7]:
performer
'N Sync                         1
24kGoldn Featuring iann dior    1
2Pac Featuring K-Ci And JoJo    1
50 Cent                         1
50 Cent Featuring Nate Dogg     1
                               ..
Zager & Evans                   1
Zayn                            1
a-ha                            1
fun. Featuring Janelle Monae    1
matchbox twenty                 1
Length: 759, dtype: int64
In [8]:
one_hit_artists_list = performer_hits[performer_hits == 1].index.tolist()
Out[8]:
["'N Sync",
 '24kGoldn Featuring iann dior',
 '2Pac Featuring K-Ci And JoJo',
 '50 Cent',
 '50 Cent Featuring Nate Dogg',
 '50 Cent Featuring Olivia',
 '6ix9ine & Nicki Minaj',
 '? (Question Mark) & The Mysterians',
 'A Taste Of Honey',
 'ABBA',
 'AWB',
 'Aaliyah',
 'Ace Of Base',
 'Aerosmith',
 'Air Supply',
 'Akon',
 'Akon Featuring Snoop Dogg',
 'Al Green',
 'Al Wilson',
 "Alan O'Day",
 'Alannah Myles',
 'All-4-One',
 'Amii Stewart',
 'Amy Grant',
 'Andy Kim',
 'Anita Ward',
 'Anne Murray',
 'Archie Bell & The Drells',
 'Aretha Franklin',
 'Aretha Franklin & George Michael',
 'Ariana Grande & Justin Bieber',
 'Ashanti',
 'Atlantic Starr',
 'Avril Lavigne',
 'B.o.B Featuring Bruno Mars',
 'B2K & P. Diddy',
 'BLACKstreet (Featuring Dr. Dre)',
 'Baauer',
 'Bachman-Turner Overdrive',
 'Bad English',
 'Bananarama',
 'Barbra Streisand & Neil Diamond',
 'Barbra Streisand/Donna Summer',
 'Barenaked Ladies',
 'Barry McGuire',
 'Barry White',
 'Bay City Rollers',
 'Belinda Carlisle',
 'Bellamy Brothers',
 'Berlin',
 'Bert Kaempfert And His Orchestra',
 'Bette Midler',
 'Beyonce Featuring Jay Z',
 'Beyonce Featuring Sean Paul',
 'Beyonce Featuring Slim Thug',
 'Bill Conti',
 'Bill Medley & Jennifer Warnes',
 'Bill Withers',
 'Billie Eilish',
 'Billy Idol',
 'Billy Paul',
 'Billy Swan',
 'Billy Vera & The Beaters',
 'Blue Swede',
 'Bo Donaldson And The Heywoods',
 'Bob Seger',
 'Bobbie Gentry',
 'Bobby "Boris" Pickett And The Crypt-Kickers',
 'Bobby Brown',
 'Bobby Darin',
 'Bobby Goldsboro',
 'Bobby Lewis',
 'Bobby McFerrin',
 'Bobby Vee',
 'Bone Thugs-N-Harmony',
 'Bonnie Tyler',
 'Boston',
 'Brandy',
 'Brandy & Monica',
 'Bread',
 'Brian Hyland',
 'Bruce Channel',
 'Bruce Hornsby & The Range',
 'Bryan Adams/Rod Stewart/Sting',
 'C+C Music Factory',
 'C.W. McCall',
 'Camila Cabello Featuring Young Thug',
 'Cardi B Featuring Megan Thee Stallion',
 'Cardi B, Bad Bunny & J Balvin',
 'Carl Douglas',
 'Carly Rae Jepsen',
 'Carly Simon',
 'Carole King',
 'Carolina Gaitan, Mauro Castillo, Adassa, Rhenzy Feliz, Diane Guerrero, Stephanie Beatriz & Encanto Cast',
 'Carrie Underwood',
 'Chamillionaire Featuring Krayzie Bone',
 'Charlie Rich',
 'Cheap Trick',
 'Childish Gambino',
 'Chris Brown',
 'Chris Brown Featuring T-Pain',
 "Christina Aguilera, Lil' Kim, Mya & P!nk",
 'Chuck Berry',
 'Ciara Featuring Petey Pablo',
 'Clay Aiken',
 'Club Nouveau',
 'Coldplay',
 'Coldplay x BTS',
 'Conway Twitty',
 'Coolio Featuring L.V.',
 'Crazy Town',
 'Creed',
 'Culture Club',
 'Cutting Crew',
 'D4L',
 'DJ Khaled Featuring Justin Bieber, Quavo, Chance The Rapper & Lil Wayne',
 'DaBaby Featuring Roddy Ricch',
 'Dale & Grace',
 'Daniel Powter',
 'Dave "Baby" Cortez',
 'David Rose and His Orchestra',
 'David Soul',
 'Dawn',
 'Dawn Featuring Tony Orlando',
 'Dean Martin',
 'Debby Boone',
 'Def Leppard',
 'Del Shannon',
 'Deniece Williams',
 'Desiigner',
 "Dexy's Midnight Runners",
 'Diana Ross & Lionel Richie',
 'Dion',
 'Dionne & Friends',
 'Dionne Warwicke & Spinners',
 'Dire Straits',
 'Divine',
 'Doja Cat Featuring Nicki Minaj',
 'Dolly Parton',
 'Domenico Modugno',
 'Don McLean',
 'Donny Osmond',
 'Donovan',
 'Drake Featuring 21 Savage',
 'Drake Featuring Future & Young Thug',
 'Drake Featuring WizKid & Kyla',
 'EMF',
 'Earth, Wind & Fire',
 'Eddie Kendricks',
 'Eddie Rabbitt',
 'Edgar Winter Group',
 'Edwin Starr',
 'Elton John & Kiki Dee',
 'Elvis Presley',
 'Eminem, Dr. Dre & 50 Cent',
 'Eric Clapton',
 'Ernie K-Doe',
 'Eurythmics',
 'Exile',
 'Expose',
 'Extreme',
 'Falco',
 'Fantasia',
 'Far*East Movement Featuring Cataracs & Dev',
 'Fergie Featuring Ludacris',
 'Fleetwood Mac',
 'Flo Rida Featuring T-Pain',
 'Foreigner',
 'Frank Sinatra',
 'Freddie And The Dreamers',
 'Freddy Fender',
 'Future Featuring Drake & Tems',
 'Gary Lewis And The Playboys',
 'Gene Chandler',
 'Genesis',
 'George McCrae',
 'George Michael/Elton John',
 "Gilbert O'Sullivan",
 'Gladys Knight And The Pips',
 'Glass Animals',
 'Glenn Medeiros Featuring Bobby Brown',
 'Gloria Estefan & Miami Sound Machine',
 'Gloria Gaynor',
 'Gordon Lightfoot',
 'Gotye Featuring Kimbra',
 'Gregory Abbott',
 "Guns N' Roses",
 'Guy Mitchell',
 'Gwen Stefani',
 'Halsey',
 'Hamilton, Joe Frank & Reynolds',
 'Hanson',
 'Harry Chapin',
 'Henry Mancini And His Orchestra',
 'Hi-Five',
 'Hollywood Argyles',
 'Hugh Masekela',
 'INXS',
 'Iggy Azalea Featuring Charli XCX',
 'Ini Kamoze',
 'Irene Cara',
 'Isaac Hayes',
 'Ja Rule Featuring Ashanti',
 'Jack Harlow',
 'James Blunt',
 'James Ingram',
 'James Taylor',
 'Jan & Dean',
 'Jan Hammer',
 'Janis Joplin',
 'Jason Derulo',
 'Jawsh 685 x Jason Derulo',
 'Jay Sean Featuring Lil Wayne',
 'Jay-Z + Alicia Keys',
 'Jeannie C. Riley',
 'Jennifer Lopez',
 'Jennifer Lopez Featuring LL Cool J',
 'Jimin',
 'Jimmy Dean',
 'Jimmy Gilmer And The Fireballs',
 'Jimmy Soul',
 'Joan Jett & the Blackhearts',
 'Joe Cocker And Jennifer Warnes',
 'Joe Dowell',
 'Joe Featuring Mystikal',
 'Joey Dee & the Starliters',
 'John Cougar',
 'John Fred And The Playboys',
 'John Legend',
 'John Lennon',
 'John Lennon With The Plastic Ono Nuclear Band',
 'John Parr',
 'John Sebastian',
 'John Travolta & Olivia Newton-John',
 'John Waite',
 'Johnnie Taylor',
 'Johnny Horton',
 'Johnny Mathis/Deniece Williams',
 'Johnny Nash',
 'Johnny Preston',
 'Johnny Rivers',
 'Jon Bon Jovi',
 'Jonas Brothers',
 'Justin Bieber Featuring Daniel Caesar & Giveon',
 'Justin Timberlake Featuring T.I.',
 'Juvenile Featuring Soulja Slim',
 'K-Ci & JoJo',
 'Kanye West',
 'Kanye West Featuring Jamie Foxx',
 'Karyn White',
 'Katy Perry Featuring Juicy J',
 'Katy Perry Featuring Kanye West',
 'Katy Perry Featuring Snoop Dogg',
 'Kendrick Lamar',
 'Kenny Loggins',
 'Kenny Rogers',
 'Kenny Rogers Duet With Dolly Parton',
 'Kim Carnes',
 'Kim Wilde',
 'Kool & The Gang',
 'Kris Kross',
 'Kyu Sakamoto',
 'LMFAO',
 'LMFAO Featuring Lauren Bennett & GoonRock',
 'Labelle',
 'Lady Gaga & Ariana Grande',
 'Lady Gaga & Bradley Cooper',
 "Lady Gaga Featuring Colby O'Donis",
 'Larry Verne',
 'Lauryn Hill',
 'Lawrence Welk And His Orchestra',
 'Leona Lewis',
 'Lesley Gore',
 'Lewis Capaldi',
 'Lil Nas X',
 'Lil Nas X & Jack Harlow',
 'Lil Nas X Featuring Billy Ray Cyrus',
 'Lil Wayne Featuring Static Major',
 'Linda Ronstadt',
 'Lipps, Inc.',
 'Lisa Loeb & Nine Stories',
 'Little Eva',
 'Little Peggy March',
 'Little Stevie Wonder',
 'Lloyd Price',
 'Londonbeat',
 'Lonestar',
 'Looking Glass',
 'Lorde',
 'Lorne Greene',
 'Los Del Rio',
 'Los Lobos',
 'Lou Christie',
 'Louis Armstrong And The All Stars',
 'Love Unlimited Orchestra',
 'Ludacris Featuring Pharrell',
 'Ludacris Featuring Shawnna',
 'Luis Fonsi & Daddy Yankee Featuring Justin Bieber',
 'Lulu',
 'M',
 'MAGIC!',
 'MFSB Featuring The Three Degrees',
 'Mac Davis',
 'Macklemore & Ryan Lewis Featuring Ray Dalton',
 'Macklemore & Ryan Lewis Featuring Wanz',
 'Manfred Mann',
 "Manfred Mann's Earth Band",
 'Mariah Carey & Boyz II Men',
 'Mariah Carey Featuring Jay-Z',
 'Mariah Carey Featuring Joe & 98 Degrees',
 'Marilyn McCoo & Billy Davis, Jr.',
 'Mario',
 'Mark Dinning',
 'Mark Ronson Featuring Bruno Mars',
 'Marky Mark & The Funky Bunch Featuring Loleatta Holloway',
 'Maroon 5 Featuring Cardi B',
 'Maroon 5 Featuring Christina Aguilera',
 'Martika',
 'Marty Robbins',
 'Mary J. Blige',
 'Mary Macgregor',
 'Mary Wells',
 'Maureen McGovern',
 'Maurice Williams & The Zodiacs',
 'Maxi Priest',
 'Meat Loaf',
 'Meco',
 'Megan Thee Stallion',
 'Meghan Trainor',
 'Melanie',
 'Michael Damian',
 'Michael Jackson With Siedah Garrett',
 'Michael Sembello',
 'Migos Featuring Lil Uzi Vert',
 'Mike + The Mechanics',
 'Mims',
 'Minnie Riperton',
 'Montell Jordan',
 'Morgan Wallen',
 'Mr. Acker Bilk',
 'Mr. Big',
 'Nancy Sinatra',
 'Nancy Sinatra & Frank Sinatra',
 'Ne-Yo',
 'Neil Young',
 'Nelly',
 'Nelly Featuring Kelly Rowland',
 'Nelly Featuring Paul Wall, Ali & Gipp',
 'Nelly Furtado',
 'Nelly Furtado Featuring Timbaland',
 'Nelly, P. Diddy & Murphy Lee',
 'Nelson',
 'Next',
 'Nick Gilder',
 'Nickelback',
 'Nicki Minaj',
 'Nilsson',
 'Nino Tempo & April Stevens',
 'OMI',
 'Otis Redding',
 'OutKast Featuring Sleepy Brown',
 'Owl City',
 'P!nk Featuring Nate Ruess',
 'P.M. Dawn',
 'Paper Lace',
 'Pat Boone',
 'Patti Austin With James Ingram',
 'Patti LaBelle & Michael McDonald',
 'Paul & Linda McCartney',
 'Paul Anka',
 'Paul Anka with Odia Coates',
 'Paul Mauriat And His Orchestra',
 'Paul McCartney And Michael Jackson',
 'Paul McCartney And Stevie Wonder',
 'Paul Simon',
 'Paul Young',
 'Paul and Paula',
 'Paula Abdul (Duet With The Wild Pair)',
 'Peabo Bryson & Regina Belle',
 'Peaches & Herb',
 'Percy Faith And His Orchestra',
 'Percy Sledge',
 'Pet Shop Boys',
 'Peter And Gordon',
 'Peter Cetera',
 'Peter Cetera With Amy Grant',
 'Peter Gabriel',
 'Peter, Paul & Mary',
 'Pharrell Williams',
 'Phil Collins and Marilyn Martin',
 'Pink Floyd',
 'Pitbull Featuring Ke$ha',
 'Pitbull Featuring Ne-Yo, Afrojack & Nayer',
 "Plain White T's",
 'Player',
 'Poison',
 'Polo G',
 'Post Malone',
 'Post Malone & Swae Lee',
 'Post Malone Featuring 21 Savage',
 'Post Malone Featuring Ty Dolla $ign',
 'Prince And The N.P.G.',
 'Puff Daddy & Faith Evans Featuring 112',
 'Puff Daddy (Featuring Mase)',
 'R. Kelly',
 'R. Kelly & Celine Dion',
 'Rae Sremmurd Featuring Gucci Mane',
 'Ray Charles and his Orchestra',
 'Ray Parker Jr.',
 'Ready For The World',
 'Rhythm Heritage',
 'Rick Dees & His Cast Of Idiots',
 'Rick Springfield',
 'Ricky Martin',
 'Right Said Fred',
 'Rihanna Featuring Britney Spears',
 'Rihanna Featuring Calvin Harris',
 'Rihanna Featuring Jay-Z',
 'Robert John',
 'Robert Palmer',
 'Robin Thicke Featuring T.I. + Pharrell',
 'Roddy Ricch',
 'Rose Royce',
 'Roy Orbison',
 'Roy Orbison And The Candy Men',
 'Ruby And The Romantics',
 'Rupert Holmes',
 'SSgt Barry Sadler',
 'SWV',
 'SZA',
 'Sam Smith & Kim Petras',
 'Sammy Davis, Jr. with The Mike Curb Congregation',
 'Santana Featuring Rob Thomas',
 'Santana Featuring The Product G&B',
 'Santo & Johnny',
 'Seal',
 'Sean Kingston',
 'Selena Gomez',
 'Shaggy Featuring Rayvon',
 'Shaggy Featuring Ricardo "RikRok" Ducent',
 'Shakira Featuring Wyclef Jean',
 'Shaun Cassidy',
 'Shawn Mendes & Camila Cabello',
 'Sheena Easton',
 'Shelley Fabares',
 'Sheriff',
 'Sia Featuring Sean Paul',
 'Silk',
 'Silk Sonic (Bruno Mars & Anderson .Paak)',
 'Silver Convention',
 'Simple Minds',
 "Sinead O'Connor",
 'Sir Mix-A-Lot',
 'Sisqo',
 'Smokey Robinson & The Miracles',
 'Snoop Dogg Featuring Pharrell',
 'Snow',
 'Sonny & Cher',
 "Soulja Boy Tell'em",
 'Spice Girls',
 'Starland Vocal Band',
 'Stars On 45',
 'Steam',
 'Steve Lacy',
 'Steve Lawrence',
 'Steve Miller',
 'Stevie B',
 'Stories',
 'Strawberry Alarm Clock',
 'Styx',
 'Surface',
 'Survivor',
 'Sweet Sensation',
 'T-Pain Featuring Yung Joc',
 'T.I.',
 'T.I. Featuring Rihanna',
 'THE SCOTTS, Travis Scott & Kid Cudi',
 'Taio Cruz Featuring Ludacris',
 'Taylor Dayne',
 'Taylor Hicks',
 'Taylor Swift Featuring Kendrick Lamar',
 "Terence Trent D'Arby",
 'Terror Squad',
 'Terry Jacks',
 'The 4 Seasons Featuring the "Sound of Frankie Valli"',
 'The Angels',
 'The Animals',
 'The Archies',
 'The Beatles With Billy Preston',
 'The Box Tops',
 'The Browns',
 'The Buckinghams',
 'The Chainsmokers Featuring Halsey',
 'The Chi-lites',
 'The Chiffons',
 'The Chipmunks With David Seville',
 'The Crystals',
 'The Dave Clark Five',
 'The Dixie Cups',
 'The Drifters',
 'The Elegants',
 'The Elton John Band',
 'The Emotions',
 'The Escape Club',
 'The Essex',
 'The Everly Brothers',
 'The Guess Who',
 'The Heights',
 'The Highwaymen',
 'The Honey Cone',
 'The Hues Corporation',
 'The J. Geils Band',
 'The Kid LAROI & Justin Bieber',
 'The Kingston Trio',
 'The Knack',
 'The Lemon Pipers',
 "The Lovin' Spoonful",
 'The Mamas & The Papas',
 'The Manhattans',
 'The Marcels',
 'The Marvelettes',
 'The McCoys',
 'The Miracles',
 'The New Vaudeville Band',
 'The Notorious B.I.G.',
 'The Notorious B.I.G. Featuring Puff Daddy & Mase',
 "The O'Jays",
 'The Osmonds',
 'The Partridge Family Starring Shirley Jones Featuring David Cassidy',
 'The Platters',
 'The Police',
 'The Raiders',
 'The Rascals',
 'The Rooftop Singers',
 'The Shangri-Las',
 'The Shocking Blue',
 'The Singing Nun (Soeur Sourire)',
 'The Sylvers',
 'The Teddy Bears',
 'The Tokens',
 'The Tornadoes',
 'The Troggs',
 'The Turtles',
 'The Tymes',
 'The Weeknd Featuring Daft Punk',
 'Thelma Houston',
 'Timbaland Featuring Nelly Furtado & Justin Timberlake',
 'Timmy T.',
 'Tina Turner',
 'Tommy Edwards',
 'Tommy Page',
 'Toni Basil',
 'Tony Orlando & Dawn',
 'Toto',
 'Travis Scott Featuring Young Thug & M.I.A.',
 'Twista Featuring Kanye West & Jamie Foxx',
 'U.S. Bonds',
 'USA For Africa',
 'Usher And Alicia Keys',
 'Usher Featuring Lil Jon & Ludacris',
 'Usher Featuring Young Jeezy',
 'Usher Featuring will.i.am',
 'Van Halen',
 'Van McCoy And The Soul City Symphony',
 'Vanessa Williams',
 'Vangelis',
 'Vanilla Ice',
 'Vertical Horizon',
 'Vicki Lawrence',
 'Walter Murphy & The Big Apple Band',
 'Wayne Fontana & The Mindbenders',
 'Wham! Featuring George Michael',
 'Whitesnake',
 'Wilbert Harrison',
 'Wild Cherry',
 'Will Smith',
 'Will Smith Featuring Dru Hill & Kool Mo Dee',
 'Will To Power',
 'Wiz Khalifa',
 'Wiz Khalifa Featuring Charlie Puth',
 'XXXTENTACION',
 'Yes',
 'Yvonne Elliman',
 'Zager & Evans',
 'Zayn',
 'a-ha',
 'fun. Featuring Janelle Monae',
 'matchbox twenty']
In [9]:
df_one_hit_wonders = df[(df['chart_position'] == 1) & df['performer'].isin(one_hit_artists_list)]
df_one_hit_wonders = df_one_hit_wonders.drop_duplicates(subset=['song', 'performer'])
df_one_hit_wonders
Out[9]:
chart_position chart_date song performer song_id instance time_on_chart consecutive_weeks previous_week peak_position worst_position chart_debut chart_url chart_year avg_chart_position
455 1 1990-09-29 (Can't Live Without Your) Love And Affection Nelson (Can't Live Without Your) Love And AffectionNe... 1.0 13 12.0 4.0 1 93 1990-07-07 https://www.billboard.com/charts/hot-100/1990-... 1990 40
953 1 1987-05-02 (I Just) Died In Your Arms Cutting Crew (I Just) Died In Your ArmsCutting Crew 1.0 9 8.0 5.0 1 80 1987-03-07 https://www.billboard.com/charts/hot-100/1987-... 1987 31
1172 1 1987-11-28 (I've Had) The Time Of My Life Bill Medley & Jennifer Warnes (I've Had) The Time Of My LifeBill Medley & Je... 1.0 10 9.0 2.0 1 73 1987-09-26 https://www.billboard.com/charts/hot-100/1987-... 1987 30
1361 1 1980-12-27 (Just Like) Starting Over John Lennon (Just Like) Starting OverJohn Lennon 1.0 9 8.0 3.0 1 38 1980-11-01 https://www.billboard.com/charts/hot-100/1980-... 1980 17
1803 1 1968-03-16 (Sittin' On) The Dock Of The Bay Otis Redding (Sittin' On) The Dock Of The BayOtis Redding 1.0 8 7.0 3.0 1 67 1968-01-27 https://www.billboard.com/charts/hot-100/1968-... 1968 15
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
335000 1 2006-03-11 You're Beautiful James Blunt You're BeautifulJames Blunt 1.0 18 17.0 2.0 1 88 2005-11-12 https://www.billboard.com/charts/hot-100/2006-... 2006 25
335508 1 1975-02-15 You're No Good Linda Ronstadt You're No GoodLinda Ronstadt 1.0 11 10.0 2.0 1 86 1974-12-07 https://www.billboard.com/charts/hot-100/1975-... 1975 34
335690 1 1973-01-06 You're So Vain Carly Simon You're So VainCarly Simon 1.0 6 5.0 4.0 1 99 1972-12-02 https://www.billboard.com/charts/hot-100/1973-... 1973 19
335871 1 1978-06-10 You're The One That I Want John Travolta & Olivia Newton-John You're The One That I WantJohn Travolta & Oliv... 1.0 11 10.0 2.0 1 65 1978-04-01 https://www.billboard.com/charts/hot-100/1978-... 1978 28
336118 1 1971-07-31 You've Got A Friend James Taylor You've Got A FriendJames Taylor 1.0 9 8.0 3.0 1 80 1971-06-05 https://www.billboard.com/charts/hot-100/1971-... 1971 17

588 rows × 15 columns

In [10]:
artists_with_staying_power_list = performer_hits[performer_hits >= 3].index.tolist()
df_artists_with_staying_power = df[df['chart_position'] == 1 & df['performer'].isin(artists_with_staying_power_list)]
df_artists_with_staying_power = df_artists_with_staying_power.drop_duplicates(subset=['song', 'performer'])
df_artists_with_staying_power
Out[10]:
chart_position chart_date song performer song_id instance time_on_chart consecutive_weeks previous_week peak_position worst_position chart_debut chart_url chart_year avg_chart_position
610 1 1991-07-27 (Everything I Do) I Do It For You Bryan Adams (Everything I Do) I Do It For YouBryan Adams 1.0 5 4.0 4.0 1 53 1991-06-29 https://www.billboard.com/charts/hot-100/1991-... 1991 22
851 1 1965-07-10 (I Can't Get No) Satisfaction The Rolling Stones (I Can't Get No) SatisfactionThe Rolling Stones 1.0 5 4.0 2.0 1 67 1965-06-12 https://www.billboard.com/charts/hot-100/1965-... 1965 14
1484 1 1978-03-04 (Love Is) Thicker Than Water Andy Gibb (Love Is) Thicker Than WaterAndy Gibb 1.0 18 17.0 2.0 1 89 1977-11-05 https://www.billboard.com/charts/hot-100/1978-... 1978 28
1710 1 1976-09-11 (Shake, Shake, Shake) Shake Your Booty KC And The Sunshine Band (Shake, Shake, Shake) Shake Your BootyKC And T... 1.0 10 9.0 5.0 1 79 1976-07-10 https://www.billboard.com/charts/hot-100/1976-... 1976 25
2084 1 1970-07-25 (They Long To Be) Close To You Carpenters (They Long To Be) Close To YouCarpenters 1.0 6 5.0 3.0 1 56 1970-06-20 https://www.billboard.com/charts/hot-100/1970-... 1970 15
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
331740 1 1986-11-29 You Give Love A Bad Name Bon Jovi You Give Love A Bad NameBon Jovi 1.0 13 12.0 4.0 1 93 1986-09-06 https://www.billboard.com/charts/hot-100/1986-... 1986 36
332177 1 1974-11-02 You Haven't Done Nothin Stevie Wonder You Haven't Done NothinStevie Wonder 1.0 14 13.0 2.0 1 93 1974-08-03 https://www.billboard.com/charts/hot-100/1974-... 1974 27
332218 1 1966-11-19 You Keep Me Hangin' On The Supremes You Keep Me Hangin' OnThe Supremes 1.0 4 3.0 7.0 1 68 1966-10-29 https://www.billboard.com/charts/hot-100/1966-... 1966 18
333687 1 1976-09-04 You Should Be Dancing Bee Gees You Should Be DancingBee Gees 1.0 10 9.0 2.0 1 67 1976-07-03 https://www.billboard.com/charts/hot-100/1976-... 1976 30
335164 1 1991-04-20 You're In Love Wilson Phillips You're In LoveWilson Phillips 1.0 11 10.0 2.0 1 64 1991-02-09 https://www.billboard.com/charts/hot-100/1991-... 1991 29

381 rows × 15 columns

In [11]:
def get_top_10_per_year(group):
    return group.nlargest(10, 'consecutive_weeks')
In [12]:
df_one_hit_wonders['Source'] = 'One Hit Wonders'
df_artists_with_staying_power['Source'] = 'Artists with Staying Power'
In [13]:
top_10_one_hit_wonders_yearly = df_one_hit_wonders.groupby('chart_year').apply(get_top_10_per_year).reset_index(drop=True)
top_10_staying_power_yearly = df_artists_with_staying_power.groupby('chart_year').apply(get_top_10_per_year).reset_index(drop=True)
In [14]:
top_10_one_hit_wonders_yearly
Out[14]:
chart_position chart_date song performer song_id instance time_on_chart consecutive_weeks previous_week peak_position worst_position chart_debut chart_url chart_year avg_chart_position Source
0 1 1958-11-29 To Know Him, Is To Love Him The Teddy Bears To Know Him, Is To Love HimThe Teddy Bears 1.0 11 10.0 3.0 1 88 1958-09-20 https://www.billboard.com/charts/hot-100/1958-... 1958 24 One Hit Wonders
1 1 1958-11-08 It's Only Make Believe Conway Twitty It's Only Make BelieveConway Twitty 1.0 9 8.0 2.0 1 65 1958-09-13 https://www.billboard.com/charts/hot-100/1958-... 1958 22 One Hit Wonders
2 1 1958-11-15 Tom Dooley The Kingston Trio Tom DooleyThe Kingston Trio 1.0 8 7.0 2.0 1 83 1958-09-27 https://www.billboard.com/charts/hot-100/1958-... 1958 19 One Hit Wonders
3 1 1958-09-27 It's All In The Game Tommy Edwards It's All In The GameTommy Edwards 1.0 7 6.0 3.0 1 96 1958-08-16 https://www.billboard.com/charts/hot-100/1958-... 1958 19 One Hit Wonders
4 1 1958-08-23 Little Star The Elegants Little StarThe Elegants 1.0 4 3.0 2.0 1 18 1958-08-02 https://www.billboard.com/charts/hot-100/1958-... 1958 18 One Hit Wonders
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
518 1 2022-08-27 Super Freaky Girl Nicki Minaj Super Freaky GirlNicki Minaj 1.0 1 NaN NaN 1 1 2022-08-27 https://www.billboard.com/charts/hot-100/2022-... 2022 22 One Hit Wonders
519 1 2022-05-14 Wait For U Future Featuring Drake & Tems Wait For UFuture Featuring Drake & Tems 1.0 1 NaN NaN 1 1 2022-05-14 https://www.billboard.com/charts/hot-100/2022-... 2022 17 One Hit Wonders
520 1 2023-04-29 Kill Bill SZA Kill BillSZA 2.0 20 16.0 4.0 1 11 2022-12-24 https://www.billboard.com/charts/hot-100/2023-... 2023 3 One Hit Wonders
521 1 2023-03-18 Last Night Morgan Wallen Last NightMorgan Wallen 1.0 6 5.0 5.0 1 27 2023-02-11 https://www.billboard.com/charts/hot-100/2023-... 2023 4 One Hit Wonders
522 1 2023-04-08 Like Crazy Jimin Like CrazyJimin 1.0 1 NaN NaN 1 1 2023-04-08 https://www.billboard.com/charts/hot-100/2023-... 2023 56 One Hit Wonders

523 rows × 16 columns

In [15]:
top_10_combined_yearly = pd.concat([top_10_one_hit_wonders_yearly, top_10_staying_power_yearly])
In [16]:
top_10_combined_yearly.rename(columns={'time_on_chart': 'Time on Chart', 'avg_chart_position': 'Average Chart Position', 'song': 'Song'}, inplace=True)
In [18]:
all_years = top_10_combined_yearly['chart_year'].unique()
all_sources = ["One Hit Wonders", "Artists with Staying Power"]

expanded_data = []

for year in all_years:
    for Source in all_sources:
        subset = top_10_combined_yearly[(top_10_combined_yearly['chart_year'] == year) & (top_10_combined_yearly['Source'] == Source)]
        if subset.empty:
            expanded_data.append({
                'chart_year': year,
                'Source': Source,
                'Average Chart Position': np.nan,
                'Time on Chart': np.nan,
                'performer': f'Placeholder {Source} {year}'
            })
        else:
            expanded_data.extend(subset.to_dict('records'))

expanded_df = pd.DataFrame(expanded_data)
In [20]:
fig = px.scatter(
    expanded_df,
    x="Average Chart Position",
    y="Time on Chart",
    animation_frame="chart_year",
    animation_group="performer",
    hover_name="performer",
    hover_data={"Song": True, "Source": False, "chart_year": False},
    color="Source",
    size_max=55,
    range_x=[top_10_combined_yearly['Average Chart Position'].max(), top_10_combined_yearly['Average Chart Position'].min()],
    range_y=[0, top_10_combined_yearly['Time on Chart'].max()]
)

x_mid = 30
y_mid = 30

fig.add_shape(
    go.layout.Shape(
        type="line",
        x0=x_mid,
        x1=x_mid,
        y0=0,
        y1=top_10_combined_yearly['Time on Chart'].max(),
        line=dict(color="Black", dash="dash", width=0.5)
    )
)

fig.add_shape(
    go.layout.Shape(
        type="line",
        x0=top_10_combined_yearly['Average Chart Position'].max(),
        x1=top_10_combined_yearly['Average Chart Position'].min(),
        y0=y_mid,
        y1=y_mid,
        line=dict(color="Black", dash="dash", width=0.5)
    )
)

fig.add_annotation(
    text="Lower Rank, long duration",
    x=x_mid + (x_mid / 2),
    y=y_mid + (y_mid / 2),
    showarrow=False
)

fig.add_annotation(
    text="High rank, long duration",
    x=x_mid - (x_mid / 2),
    y=y_mid + (y_mid / 2),
    showarrow=False
)

fig.add_annotation(
    text="High rank, short duration",
    x=x_mid - (x_mid / 2),
    y=y_mid - (y_mid / 2),
    showarrow=False
)

fig.add_annotation(
    text="Lower rank, short duration",
    x=x_mid + (x_mid / 2),
    y=y_mid - (y_mid / 2),
    showarrow=False
)

fig.update_layout(
    xaxis_title="Average Chart Position",
    yaxis_title="Total Weeks at #1"
)

fig.show()
In [ ]: